::::::::::::::::::::::::::::::::::::::::::::::::::::
'FullBallAnimation - By Brad Moore
'Placed into the public domain Oct 2004
xchg = -10
ychg = ((int(rnd(0)*8)-3) / (int(rnd(0)*3)+1))
xloc = 440
yloc = 80
NOMAINWIN
WindowWidth = 515 : WindowHeight = 303
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
graphicbox #main.gfx, 10, 10, 480, 210
button #main.go, "Go!",[go],UL, 385, 230, 105, 25
statictext #main.st1, "Speed: nn", 10, 233, 100, 25
statictext #main.st3, "Y-change: nn", 160, 233, 200, 25
Open "Window Title" for Window as #main
#main "trapclose [quit]"
#main.gfx "down; fill White; flush"
#main "font ms_sans_serif 10"
[loop]
Wait
[quit]
close #main : END
[go]
#main.gfx "color white"
timer 50 , [move]
wait
[move]
#main.st1 "Speed: " + str$(abs(xchg))
#main.st3 "Y-change: " + str$(abs(ychg))
oldx = xloc
oldy = yloc
xloc = xloc + xchg
yloc = yloc + ychg
'there is a weird bug that occasionally occurs where y can keep getting smaller
'or it can keep getting bigger - fix it here
if yloc < 0 then yloc = 0
if yloc > 210 then yloc = 210
#main.gfx "backcolor white"
#main.gfx "up; goto ";oldx;" ";int(oldy);"; down; circlefilled 10"
#main.gfx "backcolor red"
#main.gfx "up; goto ";xloc;" ";int(yloc);"; down; circlefilled 8"
if yloc < 2 or yloc > 208 then
ychg = ychg * -1
end if
if xloc < -2 or xloc > 482 then [changedirection]
wait
[changedirection]
'adjust the ball speed (x direction of travel)
ballspeed = int(rnd(0)*4)-1
direction = -1
if xchg < 0 then direction = 1
xchg = abs(xchg)
xchg = xchg + ballspeed
if xchg < 8 then xchg = 8
if xchg > 26 then xchg = 26
xchg = xchg * direction
'adjust the ball's defelction angle (y direction of travel)
direction = 1
if ychg < 0 then direction = -1
ychg = abs(ychg)
ychg = ychg + ((int(rnd(0)*9)-3) / (int(rnd(0)*3)+1))
if ychg < 0 then ychg = 0
if ychg > 10 then ychg = 11.25
ychg = ychg * direction
wait
Goto PREVIOUS section
Introduction | Let's Get Drawing | Follow the bouncing ball | Getting Control! | Appendix A | Appendix B